package com.zq.多线程设计模式.单线程模式;

/**
 * @author Jiu
 * @description：TODO
 * @date 2021/04/07   14:34
 **/
public class FlightSecurityTest {
    static class Passengers extends Thread {
        // 机场安检类
        private final FlightSecurity flightSecurity;
        // 旅客身份证
        private final String idCard;
        // 旅客登机牌
        private final String boardingPass;

        public Passengers(FlightSecurity flightSecurity, String idCard, String boardingPass) {
            this.flightSecurity = flightSecurity;
            this.idCard = idCard;
            this.boardingPass = boardingPass;
        }

        @Override
        public void run() {
            while (true) {
                // 旅客不断地过安检
                flightSecurity.pass(boardingPass, idCard);
            }
        }
    }

    public static void main(String[] args) {
        // 定义三个旅客，身份证和登机牌首位均相同
        final FlightSecurity flightsecurity = new FlightSecurity();
        new Passengers(flightsecurity, "Al23456", "AF123456").start();
        new Passengers(flightsecurity, "B123456", "BF123456").start();
        new Passengers(flightsecurity, "C123456", "CF123456").start();
    }

}
